//
//  HSYBaseCollectionViewCell.m
//  高仿暴走斗图
//
//  Created by huangsongyao on 16/3/4.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "HSYBaseCollectionViewCell.h"
#import "NSObject+DrawLine.h"
#import "UIColor+Hex.h"

@interface HSYBaseCollectionViewCell ()

@property (nonatomic, strong, readonly) UIImageView *arrowsImageView;

- (void)addArrows:(BOOL)arrows;
@end

@implementation HSYBaseCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
      
        self.backgroundColor = CLEAR_COLOR;
        
        UIImageView *imageView = [NSObject createImgWithImage:[[HSYColorHelper shareInstance] canvasImageWithColor:CLEAR_COLOR]
                                                       hImage:[[HSYColorHelper shareInstance] canvasImageWithColor:[UIColor grayColor]]
                                                clipsToBounds:YES
                                                      vcModel:UIViewContentModeScaleToFill];
        imageView.frame = self.contentView.bounds;
        [self.contentView addSubview:imageView];
        
        
    }
    return self;
}


#pragma mark - Add Arrow Image

- (void)addArrows:(BOOL)addArrows {
    
    if (addArrows && !self.arrowsImageView) {
        _arrowsImageView = [NSObject createImgWithImage:CREATE_IMG(ARROWE_IMG)
                                                 hImage:CREATE_IMG(ARROWE_IMG)
                                          clipsToBounds:YES
                                                vcModel:UIViewContentModeScaleToFill];
        [self.contentView addSubview:self.arrowsImageView];

        CGFloat size    = 20.0f;
        CGFloat right   = 15.0f;
        CGFloat x       = self.contentView.viewWidth - (size + right);
        self.arrowsImageView.frame = CGRectMake(x, 0, size, size);
        [self.arrowsImageView setCenter:CGPointMake(self.arrowsImageView.viewCenterX, self.contentView.viewCenterY)];
    }
    
}




#pragma mark - Setting To Update Layer

- (void)setIsAddBottomLine:(BOOL)isAddBottomLine {
    
    _isAddBottomLine = isAddBottomLine;
    if (isAddBottomLine) {
        [self setNeedsDisplay];
    }
}


#pragma mark - Draw Rect

- (void)drawRect:(CGRect)rect {
    
    [super drawRect:rect];
    
    if (self.isAddBottomLine) {
        [NSObject drawLineWithRect:self.contentView.bounds lineColor:[[HSYColorHelper shareInstance] lineColor] alpha:1.0f lWidth:0.3f lineType:kDrawLineTypeBottom];   //重画线条
    }
}

@end
